<?php 
	defined('IN_ADMIN') or exit('No permission resources.');
	include $this->admin_tpl('header', 'admin');
?>
<script type="text/javascript" src="<?php echo JS_PATH?>jquery.sgallery.js"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
    <a class="add fb" href="<?=$big_menu0?>"><em><?php echo L('adddir')?></em></a>
    <a class="add fb" href="<?=$big_menu1?>"><em><?php echo L('addfile')?></em></a>
    </div>
</div>
<div class="pad-lr-10">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td><div class="explain-col">
		<?php if($dir !='' and $dir != '.') {?>
		当前目录：<a href="?m=attachment&c=file&a=index&dir=<?=$dir?>"><?php echo $local?></a>
		&nbsp;&nbsp;&nbsp;<a href="<?php echo '?m=attachment&c=file&a=index&dir='.stripslashes(dirname($dir))?>"><img src="<?php echo IMG_PATH?>folder-closed.gif" /><?php echo L("parent_directory")?></a>
		<?php }else{?>
		当前目录：<a href="?m=attachment&c=file&a=index"><?php echo $local?></a>
		<?php }?>
		</div>
		</td>
		</tr>
    </tbody>
</table>
<div class="table-list">
<form name="myform" action="?m=admin&c=role&a=listorder" method="post" id="myform">
    <table width="100%" cellspacing="0">
        <thead>
		<tr>
		<th width="10%"><?php echo L('delete')?></th>
		<th width="10%" ><?php echo L('filename')?></th>
		<th width="20%" ><?php echo L('filesize')?></th>
		<th width="10%" ><?php echo L('filetype')?></th>
		<th width="20%" ><?php echo L('uploadtime')?></th>
		<th width="15%" ><?php echo L('operations_manage')?></th>
		</tr>
        </thead>
        
    <tbody>
<?php 
if(is_array($lists)){
	foreach($lists as $data){
?>
<tr>
<td width="10%" align="center"><input type="checkbox" name="fileNames[]" value="<?php echo $data['filename']?>" id="att_<?php echo $data['filename']?>" /></td>
<td width="20%" >
	<?php if($data['status'] == 0){?>
	<img src="<?php echo IMG_PATH;?>folder-closed.gif" style="vertical-align: middle;" /><a href="<?=$data['url']?>"><?=$data['filename']?></a>
	<?php }else{?>
	<img src="<?php echo file_icon($data['filename'],'gif');?>" style="vertical-align: middle;"/><a href="<?=$data['url']?>" target="_blank"><?=$data['filename']?></a>
	<?php }?>
</td>
<td width="10%" align="center"><?=$data['filesize']?></td>
<td width="10%"  align="center"><?=$data['filetype']?></td>
<td width="20%" align="center"><?php echo date('Y-m-d',$data['filetime'])?></td>
<td width="20%"  align="center">
	<?php if($data['status'] == 1){?>
	<a href="<?=$data['url']?>" target="_blank">预览</a> | 
	<?php }?>
	<a href="javascript:;" onclick="dodel('<?=$data['filename']?>');">删除</a>
</td>
</tr>
<?php 
	}
}
?>
</tbody>
</table>
<div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onClick="document.myform.action='?m=attachment&c=file&a=delAll&dir=<?=$dir?>';return confirm('<?php echo L('del_confirm')?>')"/></div>
 <div id="pages"> <?php echo $pages?></div>

</form>

</div>
</div>
</body>
</html>
<script type="text/javascript">
<!--
window.top.$('#display_center_id').css('display','none');
function dodel(filename) {
    var dir = "<?=$dir?>";
    $.ajax({
        type: "POST",
        url: "?m=attachment&c=file&a=delFile&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
        cache: false,
        dataType: "json",
        data: {'filename':filename, 'dir':dir},
        beforeSend: function(XMLHttpRequest)
        {
            if (!confirm('确认要删除？')) {
                return false;
            }
        },
        success: function(result) {
            if (result['status'] == 1) {
                alert(result['info']);
                window.location.reload();
            } else {
                alert(result['info']);
            }
        },
        error: function() {
            alert('请求服务器失败');
        }
    });
}
function preview(id, name,filepath) {
	if(IsImg(filepath)) {
		window.top.art.dialog({title:'<?php echo L('preview')?>',fixed:true, content:'<img src="'+filepath+'" onload="$(this).LoadImage(true, 500, 500,\'<?php echo IMG_PATH?>s_nopic.gif\');"/>'});	
	} else {
		window.top.art.dialog({title:'<?php echo L('preview')?>',fixed:true, content:'<a href="'+filepath+'" target="_blank"><img src="<?php echo IMG_PATH?>admin_img/down.gif"><?php echo L('click_open')?></a>'});
	}
}

function att_delete(obj,aid){
	 window.top.art.dialog({content:'<?php echo L('del_confirm')?>', fixed:true, style:'confirm', id:'att_delete'}, 
	function(){
	$.get('?m=attachment&c=manage&a=delete&aid='+aid+'&pc_hash=<?php echo $_SESSION['pc_hash']?>',function(data){
				if(data == 1) $(obj).parent().parent().fadeOut("slow");
			})
		 	
		 }, 
	function(){});
};

function showthumb(id, name) {
	window.top.art.dialog({title:'<?php echo L('att_thumb_manage')?>--'+name, id:'edit', iframe:'?m=attachment&c=manage&a=pullic_showthumbs&aid='+id ,width:'500px',height:'400px'});
}
function hoverUse(target){
	if($("#"+target).css("display") == "none"){
		$("#"+target).show();
	}else{
		$("#"+target).hide();
	}
}

function IsImg(url){
	  var sTemp;
	  var b=false;
	  var opt="jpg|gif|png|bmp|jpeg";
	  var s=opt.toUpperCase().split("|");
	  for (var i=0;i<s.length ;i++ ){
	    sTemp=url.substr(url.length-s[i].length-1);
	    sTemp=sTemp.toUpperCase();
	    s[i]="."+s[i];
	    if (s[i]==sTemp){
	      b=true;
	      break;
	    }
	  }
	  return b;
}
//-->
</script>